package com.globalwave.common
{
	import com.globalwave.common.CheckBox;
	import com.globalwave.util.U;
	
	import mx.collections.XMLListCollection;
	import mx.containers.HBox;
	
	public class Checkboxes extends HBox
	{
		private var group:RadioButtonGroup = new RadioButtonGroup();
		public var updateObject:Object = null ;
		public var labelField:String = "label" ;
		public var valueField:String = "value" ;
		
		public function RadioButtons()
		{
			super();
			this.percentHeight = 100 ;
			this.percentWidth = 100 ;
		}
		
		public function set dataProvider(value:Object):void {
			var datas:XMLListCollection = new XMLListCollection(value as XMLList);
			for (var i:int=0 ; i < datas.length ; i ++) {
				var obj:Object = datas[i] ;
				var radio:CheckBox = new CheckBox() ;
				this.addChild(radio) ;
				radio.value = U.obj2String(obj[valueField]) ;
				radio.label = U.obj2String(obj[labelField]) ;
				radio.group = this.group ;
			}
		}
		
		
		public function set selectedValue(value:String):void {
		    this.group.selectedValue = value ;
		}
		
		public function get selectedValue():String {
		    return U.obj2String(this.group.selectedValue) ;
		}
	}
}